#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

void Swap(int* p1, int* p2)
{
	int tmp = *p1;
	*p1 = *p2;
	*p2 = tmp;

}

void BubbleSort(int* a, int n)
{
	int i = 0;
	for (i = 0; i < n-1; i++)
	{
		int j = 0;
		int flag = 0;
		for (j = 0;j < n - i - 1; j++)
		{
			if(a[j] > a[j + 1])
			{
				Swap(&a[j], &a[j + 1]);
				flag = 1;
			}
		}
		if (flag == 0)
		{
			break;
		}
	}
}

int main()
{
	int a[] = { 6,9,8,1,3,5,6,-6,-5,-7 };
	int len = sizeof(a) / sizeof(int);
	int i = 0;
	BubbleSort(a, len);
	for (i = 0; i < len; i++)
	{
		printf("%d ", a[i]);
	}
}